import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import HomeView from '../views/HomeView.vue';
import ResourceView from '../views/ResourceView.vue';
import ResourceManager from '../views/ResourceManager.vue';
import ScreenData from '../views/ScreenData.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'index',
    component: () => import('../views/Index.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login.vue'),
  },
  {
    path: '/resource',
    name: 'home',
    component: HomeView,
    redirect: '/resource/resource-view',
    children: [
      {
        path: '/resource/resource-view',
        name: 'resourceView',
        component: ResourceView,
        meta: {
          activeMenu: '/resource',
        },
      },
      {
        path: '/resource/resource-manager',
        name: 'resourceManager',
        component: ResourceManager,
        meta: {
          activeMenu: '/resource',
        },
      },
      {
        path: '/resource/analyse',
        name: 'analyse',
        component: () => import('../views/Production.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/analyse`,
        },
      },
      {
        path: '/resource/factory',
        name: 'factory',
        component: () => import('../views/FactoryView.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/factory`,
        },
      },
      {
        path: '/resource/put-storage',
        name: 'putStorage',
        component: () => import('../views/PutStorage.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/put-storage`,
        },
      },
      {
        path: '/resource/out-warehouse',
        name: 'outWarehouse',
        component: () => import('../views/OutWarehouse.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/out-warehouse`,
        },
      },
      {
        path: '/resource/mushroomout',
        name: 'mushroomout',
        component: () => import('../views/Mushroom.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/out-mushroomout`,
        },
      },
      {
        path: '/resource/monitor',
        name: 'monitor',
        component: () => import('../views/monitor.vue'),
        meta: {
          isSingle: true,
          activeMenu: `/resource/monitor`,
        },
      },
    ],
  },
  {
    path: '/assist',
    name: 'assist',
    component: HomeView,
    redirect: '/assist/screen-data',
    children: [
      {
        path: '/assist/screen-data',
        name: 'screenData',
        component: ScreenData,
        meta: {
          activeMenu: '/assist',
        },
      },
    ],
  },
  {
    path: '/system',
    name: 'system',
    component: HomeView,
    redirect: '/system/user',
    children: [
      {
        path: '/system/user',
        name: 'systemUser',
        component: () => import('../views/User.vue'),
        meta: {
          activeMenu: '/system',
        },
      },
    ],
  },
  // {
  //   path: '/:pathMatch(.*)',
  //   redirect: '/',
  // },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});
// router.beforeEach((from, to, next) => {

// });
export default router;
